package com.wwg.cms.service.impl;

import java.util.Collection;
import com.wwg.cms.bo.*;
import com.wwg.cms.service.*;
import com.css.framework.dao.GeneralDao;

import com.wwg.cms.bo.entity.*;

/**
 * 
 * create by wwl
 * 
 * @author wwl
 */
public class CategoryServiceImpl implements CategoryService{

    private GeneralDao generalDao;
      
    public void setGeneralDao(GeneralDao generalDao) {
	        this.generalDao = generalDao;
	}
    
   
    
    /**
	 *获取所有
	 */
	public Collection getCategoryList(){
     String hsql="select ent from CategoryEntity as ent ";
     return generalDao.find(hsql);
    
    }
	
	/**
	 * 添加
	 * @param category 
	 * @return
	 */
	public Category addCategory(Category category){
   
			generalDao.save(category);
		    
    return category;
    
    }
	
	/**
	 * 修改
	 * @param category 
	 * @return
	 */
	public  Category updateCategory(Category category){
    
            generalDao.saveOrUpdate(category); 
	
        
        return category;
    }
	
	/**
	 * 删除
	 * @param category 
	 * @return
	 */
	public Category deleteCategory(Category category){
      		generalDao.delete(category);
		
        return category;
    }
    
    /**
     *  获取 by id
     *  @param id 编号
     * @return
	 */
    public Category getCategoryById(Long id){
    
   
     return (Category)generalDao.fetch(id,CategoryEntity.class);
    
    }
    
}
